import type { BaseQueryFn } from '@reduxjs/toolkit/query'
import type { EndpointBuilder } from '@reduxjs/toolkit/query/react'

// 基础查询类型
export type ApiEndpointBuilder = EndpointBuilder<
  BaseQueryFn,
  TagTypes,
  'api'
>

// 分页响应接口
export interface PaginatedResponse<T> {
  content: T[]
  totalPages: number
  totalElements: number
  size: number
  number: number
  first: boolean
  last: boolean
  empty: boolean
}

// API 错误接口
export interface ApiError {
  status: number
  data: {
    message: string
    errors?: Record<string, string[]>
  }
}

// API 响应接口
export interface ApiResponse<T> {
  data: T
  message: string
  success: boolean
}

// 标签类型
export type TagTypes =
  | 'Article'
  | 'Comment'
  | 'Category'
  | 'Tag'
  | 'User'
  | 'Setting'
  | 'Log'
  | 'Stats'
  | 'Search'
  | 'Notification'

// 标签描述类型
export type TagDescription = {
  type: TagTypes
  id?: string | number
}

// 排序方向
export type SortDirection = 'asc' | 'desc'

// 基础分页参数
export interface PaginationParams {
  page?: number
  size?: number
  sort?: string
  direction?: SortDirection
}

// 基础搜索参数
export interface SearchParams extends PaginationParams {
  query?: string
  filters?: Record<string, string | number | boolean>
} 